# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project Name: luffcity study project
File Name: class_test.py
Author: kij
Create Date: 2021/2/27
-------------------------------------------------
"""


# class Kij:
# 	def __init__(self, name, age):
# 		self.name = name
# 		self.age = age
#
#
# kij1 = Kij('张坤', 30)
# kij2 = Kij('张坤', 30)
# # 开辟两块不同的内存地址  就算参数一样
# print(id(kij1))  # 140227689095120
# print(id(kij2))  # 140227689095024
# kij2.country = 'sucun'
# # 新增的变量只在自己的名称空间中新增 其他对象中不受影响
# print(kij1.__dict__)  # {'name': '张坤', 'age': 30}
# print(kij2.__dict__)  # {'name': '张坤', 'age': 30, 'country': 'sucun'}
# # 将一个对象赋值给另外一个  内存地址的赋予 都好使一个东西
# kij3 = kij1
# kij3.country = kij2.country
# # 这个时候三个对象的country内存地址一样都是2的country地址
# print(id(kij1.country))  # 140682931470192
# print(id(kij2.country))  # 140682931470192
# print(id(kij3.country))  # 140682931470192
# # kij2.country开辟一块新的内存地址
# kij2.country = 'liyi'
# print(id(kij2.country))  # 140682931470256
#
# print(id(kij3))  # 和kij1内存地址一样140682931490768
# print(kij1.__dict__)  # {'name': '张坤', 'age': 30, 'country': 'sucun'}
# print(kij2.__dict__)  # {'name': '张坤', 'age': 30, 'country': 'liyi'}
# print(kij3.__dict__)  # {'name': '张坤', 'age': 30, 'country': 'sucun'}


# class Person(object):
# 	country = "中国"
#
# 	def __init__(self, name, age):
# 		self.name = name
# 		self.age = age
#
# 	def show(self):
# 		# message = "{}-{}-{}".format(Person.country, self.name, self.age)
# 		message = "{}-{}-{}".format(self.country, self.name, self.age)
# 		print(message)
#
#
# print(Person.country)  # 中国
#
# p1 = Person("武沛齐", 20)
# p1.show()  # 中国-武沛齐-20
# p1.country = '美国'  # 美国
# print(p1.country)  # 美国
# print(Person.country)  # 中国
#
# p1.show()  # 美国-武沛齐-20

# class Parent(object):
# 	x = 1
#
#
# class Child1(Parent):
# 	pass
#
#
# class Child2(Parent):
# 	pass
#
#
# print(Parent.x, Child1.x, Child2.x)  # 1 1 1
#
# Child1.x = 2
# print(Parent.x, Child1.x, Child2.x)  # 1 2 1
#
# Parent.x = 3
# print(Parent.x, Child1.x, Child2.x)  # 3 2 3
# class C(object):
# 	def __init__(self, name, age):
# 		self.name = name
# 		self.age = age
#
# 	@property
# 	def country(self):
# 		return 666
#
# 	@country.setter
# 	def country(self, age):
# 		pass
#
# 	@country.deleter
# 	def country(self, age):
# 		pass
#
#
# class D(object):
# 	def __init__(self, name, age, ):
# 		self.name = name
# 		self.age = age
#
# 	def getx(self):
# 		return 666
#
# 	def setx(self, age):
# 		pass
#
# 	def delx(self, age):
# 		pass
#
# 	x = property(getx,setx,delx,"I'm the 'x' property")
# 	# x = property(getx,None,None,"I'm the 'x' property")
#
# objd = D('kij',30)
# objd.x
# objd.x = 123
# del objd.x
#
#
# obj = C('kijlee', 30)
# obj.age
# obj.country = 'beijing'
# del obj.country

class E(object):
	def __init__(self, name, age):
		# 私有变量
		self.__name = name
		self.age = age

	def get_name(self):
		return self.__name

	# 私有方法
	def __get_age(self):
		return self.age

	# 私有属性
	@property
	def __get_country(self):
		print('测试')
		pass

	@property
	def get_my_country(self):
		self.__get_country


obj = E('kijlee', 30)
print(obj.age)
# print(obj.__name)  # 调用不到
print(obj._E__name)  # 强制调用 下划线加类名加私有变量、方法、属性等
print(obj._E__get_country)  # 强制调用 下划线加类名加私有变量、方法、属性等
print(obj.get_name())
print(obj.get_my_country)
